package top.hiai.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

import top.hiai.service.UserService;

/**
* @Author www.hiai.top
* @Email  goodsking@163.com
* @Message 更多资源尽在www.hiai.top,开发者：黄康权
* @Introduction 前天判断用户是否登录
*/

public class LoginInterceptor  implements Interceptor  {

	/**
	 * 判断用户是否登录
	 */
	public void intercept(Invocation inv) {
		// TODO Auto-generated method stub
		Controller cc = inv.getController();
		String sessionId = cc.getCookie(UserService.sessionIdName);
		if(sessionId == null ){
			inv.getController().redirect("/user/login");
		}else{
			inv.invoke();
		}
		
	}

}
